package com.xxx.video.commen.views;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;


import com.xxx.video.R;

import butterknife.ButterKnife;

public abstract class BaseDialog extends Dialog {
    /**
     * context
     */
    public Context context;

    public BaseDialog(@NonNull Context context) {
        this(context, R.style.Common_Dialog);
    }

    public BaseDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.context = context;
        View view = LayoutInflater.from(context).inflate(getContentLayout(), null);
        setContentView(view);
        ButterKnife.bind(this, view);
        initView(view);
        initListener();
        initData();
    }

    public void unBind() {
        this.context = null;
        dismiss();
    }

    /**
     * get content layout
     *
     * @return layout id
     */
    public abstract int getContentLayout();

    /**
     * init data
     */
    protected abstract void initData();

    /**
     * init Listener
     */
    protected abstract void initListener();

    /**
     * init view
     *
     * @param view view
     */
    protected abstract void initView(View view);
}
